//
//  StopLiveView.m
//  linktuIOS
//
//  Created by 章为 on 16/5/18.
//  Copyright © 2016年 张伟. All rights reserved.
//

#import "StopLiveView.h"

@interface StopLiveView()

@property (weak, nonatomic) IBOutlet UILabel *labelDate;

@property (weak, nonatomic) IBOutlet UIButton *finishButton;
@property (weak, nonatomic) IBOutlet UIButton *finishAndsaveButton;

@property (weak, nonatomic) IBOutlet UILabel *labelLiveOver;

@property (weak, nonatomic) IBOutlet UILabel *labelGet;

@property (weak, nonatomic) IBOutlet UILabel *labelShareTo;

@property (weak, nonatomic) IBOutlet UIButton *shareFristbutton;
@property (weak, nonatomic) IBOutlet UIButton *shareScondbutton;
@property (weak, nonatomic) IBOutlet UIButton *shareThridbutton;
@property (weak, nonatomic) IBOutlet UIButton *shareFourbutton;

@property (weak, nonatomic) IBOutlet UILabel *liveTimeLabel;


@property (weak, nonatomic) IBOutlet UIImageView *headerImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLable;

@property (weak, nonatomic) IBOutlet UILabel *totalViewsLable;
@property (weak, nonatomic) IBOutlet UILabel *tottalhavstLable;


@end

@implementation StopLiveView

+(instancetype)setopliveView
{
    NSArray *nib =   [[NSBundle mainBundle]loadNibNamed:@"StopLiveView" owner:self options:nil];
    StopLiveView *stopView = nib.lastObject;
    return stopView;

}

-(void)awakeFromNib
{
    [super awakeFromNib];
    _liveTimeLabel.text = NSLTLocalizedString(@"直播时长", nil);
    _labelLiveOver.text = NSLTLocalizedString(@"直播结束", nil);
    _labelGet.text = NSLTLocalizedString(@"收获", nil);
    _labelShareTo.text = NSLTLocalizedString(@"分享到", nil);
    [_finishButton setTitle:NSLTLocalizedString(@"完成并保存", nil) forState:UIControlStateNormal];
    [_finishAndsaveButton setTitle:NSLTLocalizedString(@"完成", nil) forState:UIControlStateNormal];
    
    self.totalViewsLable.hidden = YES;
    self.tottalhavstLable.hidden = YES;
    
    [self setBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.8]];
    self.finishButton.layer.cornerRadius = 20;
    self.finishButton.layer.masksToBounds = YES;
    self.finishAndsaveButton.layer.borderColor = mainButtonColor.CGColor;
    self.finishAndsaveButton.layer.borderWidth = 1;
    [self setupShareUI];
    self.frame = [UIScreen mainScreen].bounds;
    
    NSDate *date = [NSDate date];
    NSLog(@"now = %@", date);
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"yyyy/MM/dd";
    NSString *res = [formatter stringFromDate:date];
    _labelDate.text = res;
    
}
- (IBAction)FinishClick:(UIButton *)sender {
    if(self.finshBlock)
    {
        self.finshBlock(self);
    }
    
    if(self.delegate && [self.delegate respondsToSelector:@selector(stopliveCloseAndSave:)])
    {
        [self.delegate stopliveCloseAndSave:YES];
    }
    
}
- (IBAction)FinishAndSaveClick:(UIButton *)sender {
    if(self.finshandSaveBlock)
    {
        self.finshandSaveBlock(self);
    }
    if(self.delegate && [self.delegate respondsToSelector:@selector(stopliveCloseAndSave:)])
    {
        [self.delegate stopliveCloseAndSave:NO];
    }
}
- (IBAction)ShareButtonClick:(UIButton *)sender {
    if(self.shareBlcok)
    {
        self.shareBlcok(self,sender.tag - 750);
    }
    
}
-(void)setupShareUI
{
    self.shareFristbutton.tag = 754;
    self.shareScondbutton.tag = 755;
    self.shareThridbutton.tag = 756;
    self.shareFourbutton.tag  = 757;
    [self.shareFristbutton setImage:[UIImage imageNamed:@"icon_tweet_share_live"] forState:UIControlStateNormal];
    [self.shareScondbutton setImage:[UIImage imageNamed:@"icon_facebook_share_live"] forState:UIControlStateNormal];
    [self.shareThridbutton setImage:[UIImage imageNamed:@"icon_wechat_share_live@2x"] forState:UIControlStateNormal];
    [self.shareFourbutton  setImage:[UIImage imageNamed:@"icon_wechat_friend_share_live"] forState:UIControlStateNormal];

}
-(void)setTotalCount:(NSString *)totalCount
{
    _totalCount = totalCount;
    self.totalViewsLable.hidden = NO;
    self.totalViewsLable.text = _totalCount;
}
-(void)setHarvest:(NSString *)harvest
{
    _harvest = harvest;
    self.tottalhavstLable.hidden = NO;
    self.tottalhavstLable.text = harvest;
}

-(void)setAnchorModel:(MTAnchorModel *)anchorModel
{
    _anchorModel = anchorModel;
    [self.headerImageView sd_setImageWithURL:[NSURL URLWithString:anchorModel.avatar] placeholderImage:defaultImgae];
    self.nameLable.text = anchorModel.name;
}

-(void)getEndInfo{
 
    
}


@end
